package com.bckj.fastboot.upms.biz.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bckj.fastboot.core.lang.model.PageResult;
import com.bckj.fastboot.core.page.PageSupport;
import com.bckj.fastboot.upms.api.dto.SysUserQuery;
import com.bckj.fastboot.upms.api.dto.SysUserRequest;
import com.bckj.fastboot.upms.api.dto.UserAuthInfo;
import com.bckj.fastboot.upms.api.entity.SysUser;
import com.bckj.fastboot.upms.api.service.SysUserRemoteService;
import com.bckj.fastboot.upms.api.vo.SysUserVO;
import com.bckj.fastboot.upms.biz.service.SysUserService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.RequiredArgsConstructor;

import java.util.Set;


/**
 * 用户管理
 *
 * @author wfc
 * @since 2023-06-03 22:42:05
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("sysUser")
public class SysUserController implements SysUserRemoteService {

	private final SysUserService sysUserService;

	@Override
	public PageResult<SysUserVO> page(SysUserQuery query) {
		IPage<SysUserVO> page = PageSupport.page(() -> sysUserService.list(query));
		return PageResult.of(page);
	}

	@Override
	public boolean save(SysUserRequest request) {
		return sysUserService.save(request);
	}

	@Override
	public boolean update(SysUserRequest request) {
		return sysUserService.update(request);
	}

	@Override
	public SysUserVO details(@PathVariable("id") Long id) {
		return sysUserService.details(id);
	}

	@Override
	public boolean enabled(@PathVariable("id") Long id) {
		return sysUserService.enabled(id);
	}

	@Override
	public boolean remove(@PathVariable("id") Long id) {
		return sysUserService.remove(id);
	}

	@Override
	public UserAuthInfo findByUsername(String username) {
		return sysUserService.findByUsername(username);
	}

	@Override
	public boolean savePerms(SysUserRequest request) {
		return sysUserService.savePerms(request);
	}

	@Override
	public Set<SysUser> findByIds(Set<Long> ids) {
		return sysUserService.findByIds(ids);
	}
}

